#include "MemoryPCH.h"
#include "MM_MemoryNedAllocPolicy.h"
#include "MM_MemoryTracker.h"
#include <nedmalloc.c>

using namespace Memory;

//----------------------------------------------------------------------------
//NedAllocImpl
//----------------------------------------------------------------------------
void* MM_MemoryNedAllocPolicy::allocBytes(size_t count)
{
	void* ptr = nedalloc::nedmalloc(count);
	
	return ptr;
}
//---------------------------------------------------------------------
void* MM_MemoryNedAllocPolicy::allocBytesAligned(size_t count,size_t align)
{
	// default to platform SIMD alignment if none specified
	void* ptr = nedalloc::nedmemalign(align, count);

	return ptr;
}
//---------------------------------------------------------------------
void* MM_MemoryNedAllocPolicy::reallocBytes(void* ptr ,size_t count)
{
	void* newPtr = nedalloc::nedrealloc( ptr , count );

	return newPtr;
}
//---------------------------------------------------------------------
void* MM_MemoryNedAllocPolicy::reallocBytesAligned(void* ptr , size_t count ,size_t align)
{
	void* newPtr = nedalloc::nedrealloc( ptr , count );

	return newPtr;
}
//---------------------------------------------------------------------
void MM_MemoryNedAllocPolicy::deallocBytes(void* ptr)
{
	// deal with null
	if (!ptr)
		return;

	nedalloc::nedfree(ptr);
}
//---------------------------------------------------------------------
void MM_MemoryNedAllocPolicy::deallocBytesAligned(void* ptr,size_t align)
{
	// deal with null
	if (!ptr)
		return;

	nedalloc::nedfree(ptr);
}


